using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Redboil.Bfp.Model;
using NHibernate;
using Castle.Facilities.NHibernateIntegration.Components.Dao;
using Castle.Facilities.NHibernateIntegration;

namespace Redboil.Bfp.Dao.NHibernate {
    public class UserDaoImpl : IUserDao {
        private NHibernateGenericDao dao;

        public UserDaoImpl(ISessionManager sessionManager) {
            this.dao = new NHibernateGenericDao(sessionManager, "sqlite");
        }

        public User FindUserByName(String userName) {
            throw new NotImplementedException();
            //ICriteria criertia
            //var xx = dao.FindAllWithCustomQuery("from User where User.Account = '" + userName + "'") as IList<User>;
            //if(xx.Count <= 1) {
            //    return xx.First<User>();
            //}
            //else
        }

        public IList<User> FindAll() {
            //IList<User> allUsers = base.FindAll(typeof(User));
            //IList<User> disabledUser = allUsers.Where(p => p.IsDisabled == false);
            return dao.FindAll(typeof(User)) as IList<User>;
        }
    }
}